﻿Imports System.Data
Imports System.Data.OleDb
Imports geraLaudosAutomatico.conexao
Imports System.Text
Public Class cargoDAO


    Private sql As New StringBuilder
    Private objConn As New conexao
    Private i As Integer
    Private cargo As New cargoVO




    Public Function getCargos() As Generic.List(Of cargoVO)

        sql.Clear()
        sql.Append("SELECT *FROM CARGO ORDER BY DESC_CARGO")


        Dim oReader As OleDbDataReader
        Dim lista As New Generic.List(Of cargoVO)



        Try
            Dim oComando As New OleDbCommand(sql.ToString, objConn.abreConexao)

            oReader = oComando.ExecuteReader

            While oReader.Read

                cargo = New cargoVO
                cargo.ID_CARGO = oReader("ID_CARGO")
                cargo.desc_cargo = oReader("DESC_CARGO")
                cargo.status = oReader("STATUS")
                lista.Add(cargo)

            End While

            Return lista

        Catch ex As Exception

            Throw ex

        Finally

            objConn.fechaConexao()

        End Try

    End Function



    Public Function getCargo(ByVal id_cargo As Integer) As cargoVO

        sql.Clear()
        sql.Append("SELECT *FROM CARGO WHERE ID_CARGO=" & id_cargo)

        Dim oReader As OleDbDataReader
        Try
            Dim oComando As New OleDbCommand(sql.ToString, objConn.abreConexao)

            oReader = oComando.ExecuteReader

            While oReader.Read
                cargo = New cargoVO
                cargo.ID_CARGO = oReader("ID_CARGO")
                cargo.DESC_CARGO = oReader("DESC_CARGO")
                cargo.STATUS = oReader("STATUS")
            End While

            Return cargo

        Catch ex As Exception

            Throw ex

        Finally

            objConn.fechaConexao()

        End Try

    End Function

End Class
